(function($) {
	$.fn.extend({
		serializeObject : function() {
			
			var o = {};
			var a = this.serializeArray();
			$.each(a, function() {
				if (o[this.name]) {
					if (!o[this.name].push) {
						o[this.name] = [ o[this.name] ];
					}
					o[this.name].push(this.value || '');
				} else {
					o[this.name] = this.value || '';
				}
			});
			return o;
		},
		serializeString : function() {
			
			var o = {};
			var a = this.serializeArray();
			$.each(a, function() {
				if (o[this.name]) {
					if (!o[this.name].push) {
						var arr = o[this.name];
						o[this.name] = arr.join(",");
					}
					o[this.name].push(this.value || '');
				} else {
					o[this.name] = this.value || '';
				}
			});
			return o;
		},
		serializeAllArray : function() {
			var o = {};
			var a = this.serializeArray();
			$.each(a, function() {
					if (!o[this.name]) {
						o[this.name] = [];
					}
					o[this.name].push(this.value || '');
			});
			return o;
		}
	});
	
	$.fn.extend({
	    //表单加载json对象数据
	    setForm : function (jsonValue) {
	        var obj = this;
	        $.each(jsonValue, function (name, ival) {
	            var $oinput = obj.find("input[name=" + name + "]");
	            if ($oinput.attr("type") == "checkbox") {
	                if (ival !== null) {
	                    var checkboxObj = $("[name=" + name + "]");
	                    var checkArray = ival.split(";");
	                    for (var i = 0; i < checkboxObj.length; i++) {
	                        for (var j = 0; j < checkArray.length; j++) {
	                            if (checkboxObj[i].value == checkArray[j]) {
	                                checkboxObj[i].click();
	                            }
	                        }
	                    }
	                }
	            }
	            else if ($oinput.attr("type") == "radio") {
	                $oinput.each(function () {
	                    var radioObj = $("[name=" + name + "]");
	                    for (var i = 0; i < radioObj.length; i++) {
	                        if (radioObj[i].value == ival) {
	                            radioObj[i].click();
	                        }
	                    }
	                });
	            }
	            else if ($oinput.attr("type") == "textarea") {
	                obj.find("[name=" + name + "]").html(ival);
	            }
	            else {
	                obj.find("[name=" + name + "]").val(ival);
	            }
	        })

	    }
	});

})(jQuery)